package com.atguigu.juc;

import org.springframework.boot.test.context.SpringBootTest;



class piao{
    private int a =500;

    public synchronized void jian(){
        if (a>0){
        System.out.println(Thread.currentThread().getName() + (a--));
    }}
}

@SpringBootTest
public class ceshi01 {
    public static void main(String[] args) {

        piao piao = new piao();
        new Thread(()->{
            for (int i = 0; i < 50; i++) {
                piao.jian();
            }
        },"A").start();
        new Thread(()->{
            for (int i = 0; i < 50; i++) {
                piao.jian();
            }
        },"B").start();

    }
}
